/*
 五子棋程序
 */
#include <stdio.h>
int flag = 0;
int pos_x = 0,pos_y = 0;
char arr[16][16] = {};
int row = 0,col = 0;
void print(){	
	//列印棋盘
	char arr[16][16] = {};
	int row = 0,col = 0;
	for(row = 0;row <= 15;row++){
		for(col = 1;col <= 15;col++){
			if(col == 1){
					printf("%02d ",row);
			}
			if(row == 0){
				printf(" %02d ",col);
			}
			if(arr[row][col] == 0 && row !=0 && arr[row][col] != '@'&&arr[row][col] != '$'){
				printf("  * ");
			}
		}
		printf("\n");
	}
}
//交换对手
void change(){
	if(flag == 0) flag = 1;
	else  flag = 0;
}
//下棋
void walk(int pos_x,int pos_y){
	while (1){
		if(arr[pos_x][pos_y] != '*'){
			if(flag == 1){
				arr[pos_x][pos_y] = '@';
				change();
				//printf("%c",arr[pos_x][pos_y]);
				break;
			}else{
				arr[pos_x][pos_y] = '$';
				change();
				break;
			}
		}else{
			printf("该地方已经有棋子了\n");
			break;
		}
	}	
}
//判断输赢
void win(int x,int y){
	int j,k;
	int n1,n2;
	while(1){
		n1 = 0;
		n2 = 0;
		/*水平向左*/
		for(j=x,k=y;j>=1;j--){
			if(arr[j][k] == flag){
				n1++;
			}else{
				break;
			}
		for(j=x,k=y;j<=16;j++){
			if(arr[j][k] == flag){
				n2++;
			}else{
				break;
			}
		}
		if(n1+n2-1>=5){
			return (1);
		}
		/*垂直判断*/
		n1 = 0;
		n2 = 0;
		for (j=x,k=y;k >= 1;k--){
			if(arr[j][k] == flag){
				n1++;
			}else{
				break;
			}
		}
	}	
}
//主函数
int main(){
	int arr[16][16] = {};
	int row = 0,col = 0;
	print();
	printf("请%s方下子：",flag?"黑":"白");
	scanf("%d%d",&pos_x,&pos_y);
	walk(pos_x,pos_y);
	print();
}
